package tk1.uebung3.model;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class Assortment {

	private static Assortment instance;
	private List<ProductType> productTypes;
	


	private Assortment(){
		this.productTypes = new ArrayList<ProductType>();
		retrieveProductTypes();
	}
	
	public static Assortment getInstance(){
		if(instance == null){
			instance = new Assortment();
		}
		
		return instance;
	}
	
	private void retrieveProductTypes(){
		ProductType type1 = new ProductType("iPhone 4", 600.0, 12);
		ProductType type2 = new ProductType("Mac", 1000.0, 33);
		ProductType type3 = new ProductType("iPad", 500, 20);
		
		productTypes.add(type1);
		productTypes.add(type2);
		productTypes.add(type3);
	}
	
	public List<ProductType> getProductTypes() {
		return productTypes;
	}
	
	public ProductType getProductTypeByName(String name){
		for(ProductType productType : productTypes){
			if(name.equals(productType.getName()))
				return productType;
		}
		
		return null;
	}
	
	
	
	
}
